<template>
  <div>
    <el-mail :dataFrom="dataFromMail" @queryConfigDatily="queryConfigDatily()" v-if="hasPerms('daily:config:update:phone')"/>
    <el-notification v-if="hasPerms('daily:config:update:mms')" :dataFrom="dataFromNotification" @queryConfigDatily="queryConfigDatily()"/>
    <el-voice v-if="hasPerms('daily:config:update:coice')" :dataFrom="dataFromVoice" @queryConfigDatily="queryConfigDatily()"/>
    <el-config v-if="hasPerms('daily:config:update:video')" :dataFrom="dataFromConfig" @queryConfigDatily="queryConfigDatily()"></el-config>
  </div>
</template>
<script>
import ElMail from './mail'
import ElNotification from './notification'
import ElVoice from './voice'
import {queryConfigList} from '@/api/dailyweekly/workflow'
import ElConfig from './config'
import { hasPermission } from '@/permission/index.js'
export default {
  name: 'systemConfig',
  data() {
    return {
      dataFromMail: {},
      dataFromNotification: {},
      dataFromVoice: {},
      dataFromConfig: {}
    }
  },
  components: {
    ElMail,
    ElNotification,
    ElVoice,
    ElConfig
  },
  created () {
    this.queryConfigDatily()
  },
  methods: {
    hasPerms: function (perms) {
      // 根据权限标识和外部指示状态进行权限判断
      // return true
      return hasPermission(perms) & !this.disabled
    },
    async queryConfigDatily () {
      const data = await queryConfigList()
      if (data) {
        if (data.code === 200) {
          this.dataFromMail = data.data.dailyConfig
          this.dataFromNotification = data.data.mmsConfig
          this.dataFromVoice = data.data.coiceConfig
          this.dataFromConfig = data.data.videoMasConfig
        }
      }
    }
  }
}
</script>
<style>
  .hljs{
    line-height: 1.8;
    font-family: Menlo,Monaco,Consolas,Courier,monospace;
    font-size: 12px;
    padding: 18px 24px;
    background-color: #fafafa;
    border: 1px solid #eaeefb;
    margin-bottom: 25px;
    border-radius: 4px;
    -webkit-font-smoothing: auto;
  }
  .system{
    font-size: 20px;
    text-align: left;
    line-height: 40px;
    margin-top: -10px;
    font-weight: bold;
  }
</style>
